package com.brillilab.service.core.method.impl;

import com.brillilab.dao.mapper.method.MethodLabViewMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.method.MethodLabViewMapper;
import com.brillilab.domain.po.method.MethodLabView;
import com.brillilab.service.core.method.IMethodLabViewService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import javax.annotation.Resource;

import javax.annotation.Resource;

/**
 * @author wuzhiyu
 * @Title: MethodLabViewServiceImpl
 * @ProjectName brill_lab
 * @Description: TODO
 * @date 2019/2/2310:23
 */
@Service
@Transactional
public class MethodLabViewServiceImpl implements IMethodLabViewService {
    @Resource
    private MethodLabViewMapper methodLabViewMapper;
    /*********************************wuzhiyu**************************************/
    @Override
    public boolean save(MethodLabView view) {
        return methodLabViewMapper.insert(view)>0;
    }

    @Override
    public MethodLabView getByInitMethodId(Long initMethodId) {
        LambdaQueryWrapper<MethodLabView> query = new LambdaQueryWrapper<>();
        query.eq(MethodLabView::getInitMethodId,initMethodId);
        return methodLabViewMapper.selectOne(query);
    }

    @Override
    public boolean updateById(MethodLabView labView) {
        Assert.notNull(labView,"参数缺失！");
        return methodLabViewMapper.updateById(labView) > 0;
    }
    /*********************************黎剑*******************************************/
    @Override
    public MethodLabView selectOne(Long labId,Long userId,Long thirdTypeId) {
        return null;
    }

	@Override
	public int getMethodCount(Long labId) {
		 LambdaQueryWrapper<MethodLabView> query = new LambdaQueryWrapper<>();
	        query.eq(MethodLabView::getLabId,labId);
	        return methodLabViewMapper.selectCount(query);
	}
}
